<template>
  <div class="my-product">
    <h3>标题: {{ title }}</h3>
    <p>价格:{{ price }}元</p>
    <p>{{ info }}</p>
    <button @click="sum">砍一刀</button>
  </div>
</template>

<script>
export default {
 
  // props: ["title", "price", "info", "id"],
   props:{
    title:{
      required:true,
      type:String,
     
    },
     price:{
      required:true,
      type:Number,
     
    },
     info:{
     default:"酸爽可口",
      type:String,
     
    },
     id:{
      required:true,
      type:Number,
     
    },
   },

  methods: {
    sum() {
      // id 记住写this.id
      this.$emit("kanjia", 2, this.id);
    },
  },
};
</script>

<style>
.my-product {
  width: 400px;
  padding: 20px;
  border: 2px solid #000;
  border-radius: 5px;
  margin: 10px;
}
</style>